#!/usr/bin/env python
"""
# -*- coding: utf-8 -*-
# @Time    : 2020/9/16 17:38
# @Author  : AshJo
# @Desc    : 三级菜单实现
# @Filename: three_menu.py
# @Version : v1.0
"""

menu = {
    '广州': {
        '荔湾': {},
        '天河': {},
        '花都': {},
    },
    '佛山': {
        '顺德': {'大良': {'嘉信'},
               '容桂': {
                   '青华路': {'青华市场'},
                   '容山路': {},
               },
               '北滘': {},
               },
        '禅城': {},
        '南海': {},
    },
    '东莞': {
        '南城': {},
        '东城': {},
        '松山湖': {},

    }
}


def menu_func(menu):
    while True:
        for name in menu:
            print(name)
        key = input('>>>').strip()
        if menu.get(key):
            dic = menu[key]
            flag = menu_func(dic)
            if not flag:
                return False
        elif key.upper() == 'B':
            return True
        elif key.upper() == 'Q':
            return False


menu_func(menu)
print('wahaha!')
